/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            adminOweFeeDetailInfo: {
                fees: [],
                floors: [],
                total: 0,
                records: 1,
                moreCondition: false,
                title: '',
                feeTypeCds: [],
                communitys:[],
                totalPreferentialAmount: 0.0,
                allOweAmount: 0.0,
                conditions: {
                    floorId: '',
                    floorName: '',
                    roomNum: '',
                    objNameLike: '',
                    feeTypeCd: '',
                    startTime: '',
                    endTime: '',
                    communityId: '',
                    ownerNameLike:'',
                }
            }
        },
        _initMethod: function () {
            vc.emit('communityFloorTree', 'initCommunityFloorTree',{
                callName:'adminOweFeeDetail'
            })
            vc.initDate('startTime',function(_value){
                $that.adminOweFeeDetailInfo.conditions.startTime = _value;
            });
            vc.initDate('endTime',function(_value){
                $that.adminOweFeeDetailInfo.conditions.endTime = _value;
            });
            vc.getDict('pay_fee_config', "fee_type_cd", function (_data) {
                $that.adminOweFeeDetailInfo.feeTypeCds = _data
            });
            $that._listOweFees(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('adminOweFeeDetail', 'selectCommunity', function (_param) {
                $that.adminOweFeeDetailInfo.conditions.communityId = _param.communityId;
                $that.adminOweFeeDetailInfo.conditions.floorId = '';
                $that._listOweFees(DEFAULT_PAGE,DEFAULT_ROWS);
            });
            vc.on('adminOweFeeDetail', 'selectFloor', function (_param) {
                $that.adminOweFeeDetailInfo.conditions.communityId = '';
                $that.adminOweFeeDetailInfo.conditions.floorId = _param.floorId;
                $that._listOweFees(DEFAULT_PAGE,DEFAULT_ROWS);

            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listOweFees(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            //查询
            _queryMethod: function () {
                $that._listOweFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetMethod: function () {
                $that._resetFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //查询方法
            _listOweFees: function (_page, _rows) {
                $that.adminOweFeeDetailInfo.conditions.page = _page;
                $that.adminOweFeeDetailInfo.conditions.row = _rows;
                let param = {
                    params: $that.adminOweFeeDetailInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/fee.queryAdminOweFeeDetail',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.adminOweFeeDetailInfo.total = _json.total;
                        $that.adminOweFeeDetailInfo.records = _json.records;
                        $that.adminOweFeeDetailInfo.fees = _json.data;
                        //计算小计
                        let _totalPreferentialAmount = 0.0;
                        _json.data.forEach(item => {
                            _totalPreferentialAmount += parseFloat(item.oweAmount);
                        });
                        $that.adminOweFeeDetailInfo.totalPreferentialAmount = _totalPreferentialAmount.toFixed(2);
                        if (_json.data.length > 0) {
                            $that.adminOweFeeDetailInfo.allOweAmount = _json.data[0].allOweAmount;
                        } else {
                            $that.adminOweFeeDetailInfo.allOweAmount = 0.0.toFixed(2);
                        }
                        vc.emit('pagination', 'init', {
                            total: $that.adminOweFeeDetailInfo.records,
                            dataCount: $that.adminOweFeeDetailInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //重置方法
            _resetFees: function (_page, _rows) {
                $that.adminOweFeeDetailInfo.conditions.floorName = "";
                $that.adminOweFeeDetailInfo.conditions.floorId = "";
                $that.adminOweFeeDetailInfo.conditions.objName = "";
                $that.adminOweFeeDetailInfo.conditions.startTime = "";
                $that.adminOweFeeDetailInfo.conditions.endTime = "";
                $that.adminOweFeeDetailInfo.roomUnits = [];
                $that._listOweFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.adminOweFeeDetailInfo.moreCondition) {
                    $that.adminOweFeeDetailInfo.moreCondition = false;
                } else {
                    $that.adminOweFeeDetailInfo.moreCondition = true;
                }
            },
            // _exportExcel: function () {
            //     vc.jumpToPage('/callComponent/exportReportFee/exportData?pagePath=adminOweFeeDetail&' + vc.objToGetParam($that.adminOweFeeDetailInfo.conditions));
            // },
           
        }
    });
})(window.vc);
